package com.jiangyg.mall.member.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.member.dao.MemberLoginLogDao;
import com.jiangyg.mall.member.dto.MemberLoginLogDTO;
import com.jiangyg.mall.member.entity.MemberLoginLog;
import com.jiangyg.mall.member.vo.MemberLoginLogVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MemberLoginLogServiceImpl extends BaseServiceImpl<MemberLoginLogDao, MemberLoginLog> implements MemberLoginLogService {

    @Autowired
    public MemberLoginLogServiceImpl(MemberLoginLogDao memberLoginLogDao) {
        super(memberLoginLogDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<MemberLoginLogVO> selectPagination(Pagination<MemberLoginLogVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, MemberLoginLogVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(MemberLoginLogDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public MemberLoginLogVO selectById(Long memberLoginLogId) throws Exception {
        return this.executeSelectById(memberLoginLogId, MemberLoginLogVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> memberLoginLogIds) {
        return this.baseMapper.deleteBatchIds(memberLoginLogIds) > 0;
    }

}
